package org.lds.hotkey.common.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Objects;

/**
 * @author lidongsheng
 * @since 2024-06-05
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class AppInstanceModel {

    private Long id;

    /**
     * IP
     */
    private String ip;

    /**
     * 端口
     */
    private Integer port;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AppInstanceModel that = (AppInstanceModel) o;
        return Objects.equals(id, that.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }

    public String buildAddress() {
        return ip + ":" + port;
    }
}
